# encoding=utf-8
"""调试总结:
    1. 带有缓冲区的收发会稳定些
    2. 每次发送后最好在某个端点返回状态
    3. windows只能用winusb而不是Libusb
"""
import time
import usb.core
import usb.util

dev =  usb.core.find(idVendor=0xF056, idProduct=0x9999)
if dev is None:
    raise ValueError('Device not found')
print(dev)

# write the data
d = b"hello world"

dev.write(0x01, d)
from_device = dev.read(0x82, len(d))
# print("Device Says: {}".format(''.join([chr(x) for x in from_device])))
print("Device Says:", from_device)


